# This code is hosted on http://code.google.com/p/lenthorp/
# Freely available for use in applications, but should NOT be modified
# Email all comments to lenthorpresearch@gmail.com

import sys, os
import Settings
mainLocation = Settings.mainLocation
MySQLUsername = Settings.MySQLUsername

def initialiseSession(overrideLocation = '', printStatements = True):
    if overrideLocation != '':
        theLocation = overrideLocation
    else:
        theLocation = mainLocation
    if printStatements:
        print('... Adding directories to system path ...')
    try:
        directories = []
        directories.append(theLocation + 'Projects\\Pricing\\CalibrationEngine')
        directories.append(theLocation + 'Projects\\Pricing\\PricingEngines')
        directories.append(theLocation + 'Projects\\Pricing\\FDPricingEngine')
        directories.append(theLocation + 'Projects\\Pricing\\MCPricingEngine')
        directories.append(theLocation + 'Projects\\Pricing\\RBFPricingEngine')
        directories.append(theLocation + 'Projects\\Pricing\\Models')
        directories.append(theLocation + 'Projects\\Maths')
        directories.append(theLocation + 'Projects\\Trading')
        directories.append(theLocation + 'DataHandling')
        directories.append(theLocation + 'DataHandling' + '\\' + 'MySQLLoading')
        directories.append(theLocation + 'Auxiliary')
        directories.append(theLocation + 'RegressionTesting')
        directories.append(theLocation + 'QuantLibExtensions\\SWIG')

        for directory in directories:
            if not directory in sys.path:
                sys.path.append(directory)
    except:
        if printStatements:
            print('... ... Failed to add directories to system path ...')
        raise Exception('Critical failure')

if __name__ == '__main__':
    initialiseSession()